﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Prototype.GUI
{
    public class TextHandler
    {
        #region Fields

        private static TextHandler instance = null;
        private static SpriteFont _spriteFont;
        private static SpriteBatch _spriteBatch;

        public enum TextSize
        {
            Small,
            Medium,
            Large
        };

        #endregion Fields

        public static TextHandler Instance(SpriteFont spriteFont, SpriteBatch spriteBatch)
        {
           if (instance == null)
            {
                instance = new TextHandler(spriteFont, spriteBatch);
            }
            return instance;
        }

        private TextHandler(SpriteFont spriteFont, SpriteBatch spriteBatch)
        {
            _spriteFont = spriteFont;
            _spriteBatch = spriteBatch;
        }

        public static void DrawText(String text, Vector2 position, Color color, float scale)
        {
            _spriteBatch.DrawString(_spriteFont, text, position, color, 0f, Vector2.Zero, scale,SpriteEffects.None, 0f);
        }

        public static void DrawCenteredText(String text, Vector2 position, Color color, float scale)
        {
            Vector2 textSize = _spriteFont.MeasureString(text);
            _spriteBatch.DrawString(_spriteFont, text, position, color, 0f, (textSize / 2), scale, SpriteEffects.None, 0f);
        }
        public static void DrawCenteredText(String text, Vector2 position, Color color, float scale, SpriteFont font)
        {
            Vector2 textSize = font.MeasureString(text);
            _spriteBatch.DrawString(font, text, position, color, 0f, (textSize / 2), scale, SpriteEffects.None, 0f);
        }


        public static void DrawText(String text, Vector2 position, Color color, SpriteFont font)
        {
            _spriteBatch.DrawString(font, text, position, color);
        }

        public static void DrawText(String text, Vector2 position, Color color)
        {
            _spriteBatch.DrawString(_spriteFont, text, position, color);
        }

        public static void DrawText(String text, Vector2 position)
        {
            _spriteBatch.DrawString(_spriteFont, text, position, Color.White);
        }
    }
}
